﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;

namespace DataTransferObject.MetaDataList
{
    public class ListItemCategoryMaster : NotifyPropertyChangeObject
    {
        private int itemCategoryID;

        private DateTime entryDate;

        private int ancestorID;
        private int noExpiryDate;

        private double customsPercent;
        private double excisePercent;
        private double vatPercent;

        private string description;
        private string other;


        public ListItemCategoryMaster()
        {
            GlobalDefaultValue.Apply(this);
            this.EntryDate = DateTime.Now;
        }

        #region Properties


        [DefaultValue(-1)]
        public int ItemCategoryID
        {
            get { return this.itemCategoryID; }
            set { ApplyPropertyChange<ListItemCategoryMaster, int>(ref this.itemCategoryID, o => o.ItemCategoryID, value); }
        }

        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EntryDate
        {
            get { return this.entryDate; }
            set { ApplyPropertyChange<ListItemCategoryMaster, DateTime>(ref this.entryDate, o => o.EntryDate, value); }
        }

        [DefaultValue(0)]
        public int AncestorID
        {
            get { return this.ancestorID; }
            set { ApplyPropertyChange<ListItemCategoryMaster, int>(ref this.ancestorID, o => o.AncestorID, value); }
        }

        [DefaultValue(0)]
        public int NoExpiryDate
        {
            get { return this.noExpiryDate; }
            set { ApplyPropertyChange<ListItemCategoryMaster, int>(ref this.noExpiryDate, o => o.NoExpiryDate, value); }
        }

        [DefaultValue(0)]
        public double CustomsPercent
        {
            get { return this.customsPercent; }
            set { ApplyPropertyChange<ListItemCategoryMaster, double>(ref this.customsPercent, o => o.CustomsPercent, value); }
        }

        [DefaultValue(0)]
        public double ExcisePercent
        {
            get { return this.excisePercent; }
            set { ApplyPropertyChange<ListItemCategoryMaster, double>(ref this.excisePercent, o => o.ExcisePercent, value); }
        }

        [DefaultValue(0)]
        public double VATPercent
        {
            get { return this.vatPercent; }
            set { ApplyPropertyChange<ListItemCategoryMaster, double>(ref this.vatPercent, o => o.VATPercent, value); }
        }

        [DefaultValue("")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<ListItemCategoryMaster, string>(ref this.description, o => o.Description, value); }
        }


        [DefaultValue("")]
        public string Other
        {
            get { return this.other; }
            set { ApplyPropertyChange<ListItemCategoryMaster, string>(ref this.other, o => o.Other, value); }
        }

        #endregion

        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("Description", "Reference cannot be blank.", delegate { return this.Description.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("AncestorID", "Command type cannot be empty.", delegate { return (this.AncestorID == 0 || this.AncestorID != this.ItemCategoryID); }));
            validationRules.Add(new SimpleValidationRule("NoExpiryDate", "No Expiry Date must greater than 0.", delegate { return (this.NoExpiryDate > 0); }));
            validationRules.Add(new SimpleValidationRule("CustomsPercent", "Customs Percent must greater than 0.", delegate { return (this.CustomsPercent > 0); }));
            validationRules.Add(new SimpleValidationRule("ExcisePercent", "Excise Percent must greater than 0.", delegate { return (this.ExcisePercent > 0); }));
            validationRules.Add(new SimpleValidationRule("VATPercent", "VAT Percent must greater than 0.", delegate { return (this.VATPercent > 0); }));


            return validationRules;
        }
    }
}

